package dp;

/**
 * 如果两间相邻的房屋在同一晚上被小偷闯入，系统会自动报警。
 *
 * @author luolidong
 * @version 1.0
 * @create 2021-07-31 11:30
 */
public class L198 {
    public int rob(int[] nums) {
        int pre = 0;
        int cur = 0;
        for (int i = 0; i < nums.length; i++) {
            int temp = Math.max(nums[i] + pre, cur);
            pre = cur;
            cur = temp;
        }
        return cur;
    }
}
